
*** This do file includes regressions based on the Afghanistan Nationwide Quarterly Assessment Research (ANQAR) survey for the paper "Foreign Interventions and Community Cohesion in Times of Conflict"	
*** Author: Sarah Langlotz		
*** Journal: Journal of Development Economics
													

***********************************************************************************************
**************************************Read me **************************************
***********************************************************************************************
*** FOLDER STRUCTURE
/* After downloading the data from the Harvard Dataverse, create the following three folders:
	- "processed"
	- "graphs"
	- "tables"
*/



***	DATA ACCESS
*	The raw ANQAR household survey data are subject to access restrictions and cannot be shared publicly. 
*	Please contact the author for information on how to request access.



***	SOFTWARE VERSION
*	Stata/MP 19.0 for Windows (64-bit x86-64), Revision 21 May 2025


***	TABLES 
* 	This dofiles created Tables 4 (Panel B) and 6


***********************************************************************************
***	Set your directory

local DIR = ""
cap cd "`DIR'"

***********************************************************************************

drop _all
clear matrix
clear mata
set maxvar 10000
set matsize 10000

set more off

clear
use "processed\finaldata_hhlevel_ANQAR_all_external.dta"


	
********************************************************************************
* TABLE 4 - Panel: Dispute shura (SAP, ANQAR), 2007-2009 (only Panel B)
********************************************************************************
	
	global short l1lnaid_wb l1vhi log_l1nightlight   

	cap drop isaf
	gen double isaf = .
	cap drop contest
	gen double contest = .
	
	
	cap est drop *

	foreach Y of varlist dispute_shura  {

    local i = 1
	foreach X of varlist ma_largebase_inbr activebase no_securityprt  {

        replace isaf = `X'
        replace contest = l1lnallsigacts

        reghdfe `Y' isaf contest  $short  if year<2011, absorb(id i.year i.wave) cluster(districtcode)
        estadd local lag "No"
		estadd local controls "Yes"
        estadd local pyfe "Yes"
        estadd local restr "Yes"
        quietly summarize year if e(sample)
        local firstyear = r(min)
        local lastyear  = r(max)
        estadd local years "`firstyear'-`lastyear'"
        est store est1_`i'_`Y'
	
        replace isaf = l1`X'

        reghdfe `Y' isaf contest  $short  if year<2011, absorb(id i.year i.wave) cluster(districtcode)
		estadd local lag "Yes"
		estadd local controls "Yes"
        estadd local pyfe "Yes"
        estadd local restr "Yes"
        quietly summarize year if e(sample)
        local firstyear = r(min)
        local lastyear  = r(max)
        estadd local years "`firstyear'-`lastyear'"
        est store est2_`i'_`Y'

        local ++i
    }

    esttab est1_1_`Y' est2_1_`Y' est1_2_`Y' est2_2_`Y' est1_3_`Y' est2_3_`Y' ///
        using "tables/Panel_Anqar_`Y'.tex", fragment booktabs se(3) b(3) ///
        star starlevels(* 0.10 ** 0.05 *** 0.01) replace ///
        mlabel(none) style(fixed) keep(isaf) order(isaf) ///
        varlabel(isaf "ISAF") ///
        stats(r2_a N  years lag, fmt(3 0 0 0) label( "Adj. R$^2$" "Observations"  "Years" "\hline Lagged")) ///
        nonumbers nogaps noabbr nolines nomtitle nonote
}

	
********************************************************************************
* TABLE 6 - Panel: Attitudes towards ISAF, 2012-2014, (ANQAR)
********************************************************************************
	
	cap est drop *

	foreach Y of varlist insec_ISAF blame_ff hatred_ff ISAF_leave {

    local i = 1
	foreach X of varlist largebase_inbr activebase   {

        replace isaf = `X'
        replace contest = l1lnallsigacts

        reghdfe `Y' isaf contest   if year<2015, absorb(id i.year i.wave) cluster(districtcode)
        estadd local lag "No"
		estadd local controls "Yes"
        estadd local pyfe "Yes"
        estadd local restr "Yes"
        quietly summarize year if e(sample)
        local firstyear = r(min)
        local lastyear  = r(max)
        estadd local years "`firstyear'-`lastyear'"
        est store est1_`i'_`Y'

        replace isaf = l1`X'

        reghdfe `Y' isaf contest    if year<2015, absorb(id i.year i.wave) cluster(districtcode)
		estadd local lag "Yes"
		estadd local controls "Yes"
        estadd local pyfe "Yes"
        estadd local restr "Yes"
        quietly summarize year if e(sample)
        local firstyear = r(min)
        local lastyear  = r(max)
        estadd local years "`firstyear'-`lastyear'"
        est store est2_`i'_`Y'

        local ++i
    }

    esttab est1_1_`Y' est2_1_`Y' est1_2_`Y' est2_2_`Y'  ///
        using "tables/Panel_Anqar_`Y'.tex", fragment booktabs se(3) b(3) ///
        star starlevels(* 0.10 ** 0.05 *** 0.01) replace ///
        mlabel(none) style(fixed) keep(isaf) order(isaf) ///
        varlabel(isaf "ISAF") ///
        stats(r2_a N years lag, fmt(3 0 0) label( "Adj. R$^2$" "Observations" "Years" "\hline Lagged")) ///
        nonumbers nogaps noabbr nolines nomtitle nonote
}
